<!doctype html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>一年中的第几天</title>
	</head>
	<body>
		<input id="year" type="text" />
		<label for="year">年</label>
		<input id="month" type="text" />
		<label for="month">月</label>
		<input id="day" type="text" />
		<label for="day">日</label>
		<input id="btn" type="button" value="计算" />
	</body>
	<script type="text/javascript">
		var btn = document.getElementById('btn');
		var year = document.getElementById('year');
		var month = document.getElementById('month');
		var day = document.getElementById('day');
		btn.onclick = function(){
			var y = Number(year.value);
			var m = Number(month.value);
			var d = Number(day.value);
			var allDay = 0;

			switch(m){
				case 12:
					allDay += 30;
				case 11:
					allDay += 31;
				case 10:
					allDay += 30;
				case 9:
					allDay += 31;
				case 8:
					allDay += 31;
				case 7:
					allDay += 30;
				case 6:
					allDay += 31;
				case 5:
					allDay += 30;
				case 4:
					allDay += 31;
				case 3:
					allDay += 28;
				case 2:
					allDay += 31;
				case 1:
					allDay += d;
			}
			if ((y%4 == 0 && y%100 != 0) || y%400 == 0) {
				if (m >= 3) {
					allDay += 1;
				}
			}
			alert(allDay);

		}









	</script>
</html>